Count number of ways to reach destination in a Maze
Given a maze[][] of dimension N X M, such that maze[i][j] = -1 represents a blocked cell and maze[i][j] = 0 represents an unblocked cell. The task is to count the number of ways to reach bottom-right cell starting from top-left cell by moving right (i, j+1) and down (i+1, j) in the maze....
read more
Number of integers in a range [L, R] which are divisible by exactly K of it’s digits
Given a range of values [L, R] and a value K, the task is to count the numbers in the given range which are divisible by at least K of the digits present in the decimal representation of that number....
read more
Maximum sum possible from given Matrix by performing given operations
Given a matrix arr[][] of dimensions 2 * N, the task is to maximize the sum possible by selecting at most one element from each column such that no two consecutive elements are chosen from the same row....
read more
Count no. of ordered subsets having a particular XOR value
Given an array arr[] of n elements and a number K, find the number of ordered subsets of arr[] having XOR of elements as K This is a modified version of this problem. So it is recommended to try that problem before.Examples:...
read more
Count all possible visited cells of a knight after N moves
Given the current position of a Knight as (i, j), find the count of different possible positions visited by a knight after N moves (in a 10 x 10 board)....
read more
Minimum length of Run Length Encoding possible by removing at most K characters from a given string
Given a string S of length N, consisting of lowercase English alphabets only, the task is to find the minimum possible length of run-length-encoding that can be generated by removing at most K characters from the string S....
read more
Maximum possible score that can be obtained by constructing a Binary Tree based on given conditions
Given an array arr[] of (N – 1) integers and each value arr[i](1-based indexing) is the score of the nodes having degree i. The task is to determine the maximum score of any tree of N nodes that can be constructed....
read more
Count all possible paths from top left to bottom right of a Matrix without crossing the diagonal
Given an integer N which denotes the size of a matrix, the task is to find the number of possible ways to reach the bottom-right corner from the top-left corner of the matrix without crossing the diagonal of the matrix. The possible movements from any cell (i, j) from the matrix are (i, j + 1) (Right) or (i + 1, j) (Down)....
read more
Maximum sum by picking elements from two arrays in order | Set 2
Given two arrays A[] and B[], each of size N, and two integers X and Y denoting the maximum number of elements that can be picked from A[] and B[] respectively, the task is to find the maximum possible sum by selecting N elements in such a way that for any index i, either A[i] or B[i] can be chosen. Note: It is guaranteed that (X + Y) >= N.Examples:...
read more
Expected number of moves to reach the end of a board | Dynamic programming
Given a linear board of length N numbered from 1 to N, the task is to find the expected number of moves required to reach the Nth cell of the board, if we start at cell numbered 1 and at each step we roll a cubical dice to decide the next move. Also, we cannot go outside the bounds of the board. Note that the expected number of moves can be fractional.Examples:...
read more
Count ways to remove pairs from a matrix such that remaining elements can be grouped in vertical or horizontal pairs
Given an integer K and a square matrix mat[][] of size N * N with elements from the range[1, K], the task is to count ways to remove pairs of distinct matrix elements such that remaining elements can be arranged in pairs vertically or horizontally....
read more
Count Subarrays with strictly decreasing consecutive elements
Given an array arr[] containing integers. The task is to find the number of decreasing subarrays with a difference of 1....
read more